<script>
	const wx = uni
	export default {
		onLaunch: function() {
			uni.getSystemInfo({
				success(res) {
					getApp().globalData.windowHeight = res.windowHeight
				}
			})
		},
		onShow: function() {
		},
		onHide: function() {
		},
		globalData: {
			http: '',
			http_A:'http://xxxxx',//地址A,正常使用
			http_B:"",//地址B,开头加'*'使用
			http_C:"",//地址C,开头加'#'使用
			windowHeight:0 //窗口可用高度
		},
		POST: function(url, params, sucessFun, errorFun) {
			var that = this
			if (!params) {
				params = {};
			}
			if (!sucessFun) {
				sucessFun = function(data) {
					if (data.status == '0') {
						console.log("执行成功");
					} else {
						console.log(data);
					}
				};
			}
			if (!errorFun) {
				errorFun = function(err) {
					console.log(err)
				};
			}
			uni.request({
				url: getapp().globalData.http + url,
				data: params,
				method: "POST",
				header: {},
				success: (res) => {
					if (res.statusCode = 200) {
						sucessFun(res)
					} else {
						uni.reLaunch({
							url: "/pages/index/index"
						})
					}
				},
				fail: (err) => {
					uni.reLaunch({
						url: "/pages/index/index"
					})
					errorFun(err)
				}
			})
		},
		GET: function(url, params, sucessFun, errorFun) {
			var that = this
			if (!params) {
				params = {};
			}
			if (!sucessFun) {
				sucessFun = function(data) {
					if (data.status == '0') {
						console.log("执行成功");
					} else {
						console.log(data);
					}
				};
			}
			if (!errorFun) {
				errorFun = function(err) {
					console.log(err)
				};
			}
			uni.request({
				url: getapp().globalData.http + url,
				data: params,
				method: "GET",
				header: {},
				success: (res) => {
					if (res.statusCode = 200) {
						sucessFun(res)
					} else {
						uni.reLaunch({
							url: "/pages/index/index"
						})
					}
				},
				fail: (err) => {
					uni.reLaunch({
						url: "/pages/index/index"
					})
					errorFun(err)
				}
			})
		}
	}
</script>

<style>
	@import '@/mypUI/base.scss';
	/* #ifdef MP */
	@import '@/mypUI/mp.scss';
	/* #endif */
	/* #ifdef H5 */
	@import '@/mypUI/h5.scss';
	/* #endif */
	/*每个页面公共css */
	page {
		background: #ECF0F1;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}
</style>
